public class demo2 {
    public String addBinary(String a, String b) {
        int left=a.length()-1;
        int right=b.length()-1;
        StringBuilder stringBuilder=new StringBuilder();
        int ret=0;
        while(left>=0||right>=0||ret!=0) {
            if(left>=0) {
                ret+=a.charAt(left)-'0';
                left--;
            }
            if(right>=0) {ret+=b.charAt(right)-'0';
                right--;
            }
            stringBuilder.append(ret%2);
            ret/=2;
        }
        return stringBuilder.reverse().toString();
    }
}
